(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const sum = require('./sum');

const arrUtil = require('./arr-utils');

// 导入第三方模块
const uniq = require('uniq');

let arr = [6,7,8];

console.log(sum(arr)); //21

console.log(arrUtil.average(arr)); //7

console.log(arrUtil.getMax(arr)); //8

// console.log(uniq); //[Function: unique]

let arr2 = [1,2,3,4,2,3,3,3,1];

// 数组去重
console.log(uniq(arr2)); //[ 1, 2, 3, 4 ]

// document is not defined
// window
document.querySelector('button').onclick = function(){
    // alert(1);

    // 写法1
    // 随机数 0-1 永远不等于1
    // let rndNum = Math.random()*100;
    // // 向下取整
    // let num = Math.floor(rndNum);


    // 写法2
    let rndNum = Math.floor(Math.random()*100);


    console.log('随机中奖号码'+rndNum);

};




},{"./arr-utils":2,"./sum":4,"uniq":3}],2:[function(require,module,exports){
const sum = require('./sum');

// 请平均值
function average(arr){
    // 求和
    let res = sum(arr);

    return res/arr.length
}

// 获取数组最大值
function getMax(arr){
    // return arr.sort((n1,n2)=>{
    //     return n2-n1;s
    // })[0];
    return Math.max(...arr);
}

module.exports = {
    average,
    getMax
}

// console.log(getMax([5,9,11,-1]));

// console.log(Math.max(5,11,7,80,-3));
},{"./sum":4}],3:[function(require,module,exports){
"use strict"

function unique_pred(list, compare) {
  var ptr = 1
    , len = list.length
    , a=list[0], b=list[0]
  for(var i=1; i<len; ++i) {
    b = a
    a = list[i]
    if(compare(a, b)) {
      if(i === ptr) {
        ptr++
        continue
      }
      list[ptr++] = a
    }
  }
  list.length = ptr
  return list
}

function unique_eq(list) {
  var ptr = 1
    , len = list.length
    , a=list[0], b = list[0]
  for(var i=1; i<len; ++i, b=a) {
    b = a
    a = list[i]
    if(a !== b) {
      if(i === ptr) {
        ptr++
        continue
      }
      list[ptr++] = a
    }
  }
  list.length = ptr
  return list
}

function unique(list, compare, sorted) {
  if(list.length === 0) {
    return list
  }
  if(compare) {
    if(!sorted) {
      list.sort(compare)
    }
    return unique_pred(list, compare)
  }
  if(!sorted) {
    list.sort()
  }
  return unique_eq(list)
}

module.exports = unique

},{}],4:[function(require,module,exports){
// 数组求和
function sum(arr) {
    return arr.reduce((pre,item)=>pre+item,0);
}

module.exports = sum;

// console.log(sum([1,2,3]));


// let arr = [8, 10, 12];

// reduce(fn,num);
    // let sum2 = arr.reduce(
    // (pre, item) => {
    //     console.log(pre, item);

    //     // 每次循环 它pre 会改变 -> 会变成这个回调函数的返回值
    //     return pre+item;
    // },5);

    // console.log(sum2);
    // 5 8
    // 6 10
    // 6 12
},{}]},{},[1]);
